﻿<Window x:Class="Cyclops.MainApplication.View.Dialogs.VcardDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
		xmlns:ViewModel="clr-namespace:Cyclops.MainApplication.ViewModel" 
		xmlns:Controls="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended" 
		xmlns:Controls1="clr-namespace:Cyclops.MainApplication.Controls" 
        xmlns:ValueConverters="clr-namespace:Cyclops.MainApplication.ValueConverters" 
        xmlns:System="clr-namespace:System;assembly=mscorlib" 
        Title="{Binding Path=Vcard.Title, Source={StaticResource ResourceWrapper}}"
        MaxHeight="261" MaxWidth="533" MinHeight="261" MinWidth="533"
		WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow" TextOptions.TextFormattingMode="Display" TextOptions.TextRenderingMode="ClearType">
	<Window.Resources>

        <ValueConverters:FalseToCollapsedValueConverter x:Key="falseToHideConverter"/>
        <ValueConverters:Invertor x:Key="invertor"/>
        
		<Style x:Key="FieldNameStyle" TargetType="{x:Type TextBlock}">
			<Setter Property="TextWrapping" Value="NoWrap"/>
			<Setter Property="TextTrimming" Value="None"/>
			<Setter Property="HorizontalAlignment" Value="Right"/>
			<Setter Property="Margin" Value="10,0"/>
			<Setter Property="VerticalAlignment" Value="Center"/>
		</Style>
		
	</Window.Resources>
    <Grid>
        <Controls:BusyIndicator IsBusy="{Binding IsBusy}" BusyContent="{Binding Path=Common.PleaseWait, Source={StaticResource ResourceWrapper}}">
        	<Grid>
        		<Grid.RowDefinitions>
        			<RowDefinition Height="6" />
        			<RowDefinition Height="30" />
        			<RowDefinition Height="30"/>
        			<RowDefinition Height="30"/>
        			<RowDefinition Height="30"/>
        			<RowDefinition Height="Auto"/>
        			<RowDefinition />	
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition Width="Auto"/>
					<ColumnDefinition/>
				</Grid.ColumnDefinitions>
                <Border Background="White" Margin="10" VerticalAlignment="Top" Grid.RowSpan="10" Grid.Row="0" Width="170" Height="166">
                	<Border.Effect>
                		<DropShadowEffect BlurRadius="2" ShadowDepth="0" Color="#99D0D0D0"/>
                	</Border.Effect>
                    <Controls1:AnimatedImage AnimatedBitmap="{Binding Photo}" />
                </Border>
                <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=Vcard.Nick, Source={StaticResource ResourceWrapper}}" Style="{DynamicResource FieldNameStyle}" />
                <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Path=Vcard.FullName, Source={StaticResource ResourceWrapper}}" Style="{DynamicResource FieldNameStyle}" />
                <TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding Path=Vcard.Birthday, Source={StaticResource ResourceWrapper}}" Style="{DynamicResource FieldNameStyle}" />
                <TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding Path=Vcard.Comments, Source={StaticResource ResourceWrapper}}" Style="{DynamicResource FieldNameStyle}" />
            	<TextBox Text="{Binding Nick, Mode=TwoWay}" Grid.Row="1" Grid.Column="2" Height="24" Margin="0,0,10,0" IsReadOnly="True"/>
                <TextBox IsReadOnly="{Binding IsEditMode, Converter={StaticResource invertor}}" Text="{Binding FullName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="2" Height="24" Margin="0,0,10,0" />
                <DatePicker IsEnabled="{Binding IsEditMode}" DisplayDateStart="{x:Static System:DateTime.Now}"
                            SelectedDate="{Binding Birthday, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                            Grid.Row="3" Grid.Column="2" Height="24" Margin="0,0,10,0"/>
                <TextBox IsReadOnly="{Binding IsEditMode, Converter={StaticResource invertor}}" 
                         Text="{Binding Comments, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="2" 
                         Height="78" Margin="0,3,10,0" Grid.RowSpan="2" TextWrapping="Wrap"
                         ScrollViewer.VerticalScrollBarVisibility="Visible"/>

                <Button IsDefault="True" Visibility="{Binding IsEditMode, Converter={StaticResource falseToHideConverter}}" Command="{Binding Save}" 
                        Grid.Row="7" Grid.Column="2" Content="{Binding Path=Common.Ok, Source={StaticResource ResourceWrapper}}" 
                        Width="70" Height="24" Margin="0,0,20,0"/>
                <Button IsCancel="True" Command="{Binding Cancel}" Grid.Row="7" Grid.Column="2" Content="{Binding Path=Common.Cancel, Source={StaticResource ResourceWrapper}}" 
                        Width="70" Height="24" 
                        HorizontalAlignment="Right" Margin="0,0,10,0"/>

                <Button Visibility="{Binding IsEditMode, Converter={StaticResource falseToHideConverter}}" 
                        Command="{Binding LoadPicture}" Height="24" Width="30" Grid.Row="7"
                        Margin="0,0,30,10" ToolTip="{Binding Path=Vcard.LoadPictureTip, Source={StaticResource ResourceWrapper}}">
                    <Image Source="..\..\Resources\Folder.png"/>
                </Button>
                <Button Visibility="{Binding IsEditMode, Converter={StaticResource falseToHideConverter}}" 
                        Command="{Binding ClearPicture}" Height="24" 
                        Margin="80,0,40,10" Width="30" Grid.Row="7"
                        ToolTip="{Binding Path=Vcard.ClearPictureTip, Source={StaticResource ResourceWrapper}}">
                    <Image Source="..\..\Resources\stop.png"/>
                </Button>

            </Grid>
			
			
        </Controls:BusyIndicator>
    </Grid>
</Window>
